package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;


// ***************************************************************************
// *** CLASS: HemsBjelkeLag
// ***************************************************************************
public class HemsBjelkeLag extends BjelkeLag
{ public double gruveWidth=1.0;
  public double gruveHeight=0.4;
    
  public HemsBjelkeLag(String ident,Point3D p0,double width,double height,double depth)
  { super(ident,p0,width,height,depth); }
  
  // ***************************************************************************
  // *** METHOD: getModel3D -- TEMP !!!
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  { 
    return(null);
  }  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { Rectangle2D.Double r=projection(direction,origo2D,scale);
    switch(direction)
    {
//      case NORTH: drawProjectionNorth(g,r,scale,c); break;
//      case SOUTH: drawProjectionSouth(g,r,scale,c); break;
//      case EAST: drawProjectionEast(g,r,scale,c); break;
//      case WEST: drawProjectionWest(g,r,scale,c); break;
//      case ABOVE: drawProjectionAbove(g,r,scale,c); break;
//      case BELOW: drawProjectionBelow(g,r,scale,c); break;
      case VCUT: drawVerticalCut(g,r,scale,c); break;
//      case HCUT: drawHorisontalCut(g,r,scale,c); break;
      default: super.drawProjection(direction,g,origo2D,scale,c);
    }
  }  
    
  private void drawVerticalCut
  (Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { double gruveWidth=this.gruveWidth*scale;
    double gruveHeight=this.gruveHeight*scale;
//    double w1=(r.width-gruveWidth)/2;
    double w1=r.width/2-gruveWidth;
    Rectangle2D.Double r1;
    Rectangle2D.Double rh1;
    Rectangle2D.Double rg;
    Rectangle2D.Double rh2;
    Rectangle2D.Double r2;
    r1=new Rectangle2D.Double(r.x,r.y,w1,r.height);
    rh1=new Rectangle2D.Double(r.x+w1-r.height,r.y,r.height,gruveHeight+r.height);
    rg=new Rectangle2D.Double(r.x+w1,r.y+gruveHeight,gruveWidth,r.height);
    r2=new Rectangle2D.Double(r.x+(2.60-0.25)*scale,r.y,(2.40+0.15)*scale,r.height);
    
    fill(g,r1,c);
    fill(g,rh1,c);
    fill(g,rg,c);
    fill(g,r2,c);

    draw(g,r1);
    draw(g,rh1);
    draw(g,rg);
    draw(g,r2);
  }

}  
